package com.mylogistics.common.Utils;

import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 用于将数据打包成json格式发送给前端
 */
public class ResponseUtil {

    public static void writeJSON(HttpServletResponse response, Object data){
        response.setCharacterEncoding("utf-8");
        response.setContentType("application/json");
        try {
            response.getWriter().write(JSON.toJSONString(data));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

